package main;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MsSQLConnect {
    public static Connection ConnectDB(String dbName) {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        String connString = "";

        if (dbName.equals("ImportFactage")) {
            connString = "jdbc:sqlserver://sdevsqlphn1d;database=importFactage;user=sa1;password=11111Q!;";
        } else if (dbName.equals("Factage")) {
            connString = "jdbc:sqlserver://ssqlphn1d;database=Factage;user=sa1;password=11111Q!;";
        }

        Connection conn = null;

        try {
            conn = DriverManager.getConnection(connString);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return conn;
    }
}
